<!-- 见证任务分配 -->
<template>
  <div class="layout-wrapper layout-witness">
    <!-- {{ wsData }} -->
    <div class="layout-header layout-search">
      <el-form :inline="true" :model="searchForm">
        <el-form-item label="行业类别">
          <el-cascader
            v-model="searchForm.industry"
            option-max-width="230px"
            class="ui-w230"
            :props="{ multiple: true }"
            collapse-tags
            :collapse-tags-max-num="1"
            :tooltip-max-width="230"
            tooltip-effect="light"
            :options="industryTypeAndIndustryData"
            clearable
            @change="industryChange"
          />
        </el-form-item>
        <el-form-item label="交易方式">
          <el-select
            v-model="searchForm.tenderMode"
            class="ui-w180"
            option-max-width="180px"
            placeholder="请选择"
            clearable
            @change="handleSearchFn()"
          >
            <!-- <el-option key label="全部" value></el-option> -->
            <el-option v-for="(label, key) in tenderModeOptionsObj" :key="key" :label="label" :value="key" />
          </el-select>
        </el-form-item>
        <el-form-item label="资审方式">
          <el-select
            v-model="searchForm.zsType"
            class="ui-w180"
            option-max-width="180px"
            placeholder="请选择"
            clearable
            @change="handleSearchFn()"
          >
            <!-- <el-option key label="全部" value></el-option> -->
            <el-option v-for="(label, key) in zsTypeOptionsObj" :key="key" :label="label" :value="key" />
          </el-select>
        </el-form-item>
        <el-form-item label="开标时间">
          <el-date-picker
            v-model="searchForm.date"
            class="ui-w260"
            unlink-panels
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :clearable="true"
            value-format="yyyy-MM-dd"
            :picker-options="pickerOptions"
            @change="handleSearchFn()"
          />
        </el-form-item>
        <el-form-item>
          <el-input
            v-model.trim="searchForm.keywords"
            class="ui-w210"
            placeholder="项目/标段/名称/编号"
            @keyup.native.enter="handleSearchFn()"
          >
            <el-button slot="append" type="primary" icon="icon-sousuo" @click="handleSearchFn()" />
          </el-input>
        </el-form-item>
      </el-form>
    </div>
    <!-- <div class="layout-header ui-mb10">
      <el-button
        type="primary"
        icon="icon-sousuo"
        plain
        @click="handleBatchApprove()"
      >
        更改见证人
      </el-button>
    </div> -->

    <el-button
      type="primary"
      style="width: 100px;margin-bottom: 10px;"
      @click="random">
      随机分配
    </el-button>
    <div class="layout-body">
      <el-table
        v-loading="tableLoading"
        :data="tableData"
        highlight-current-row
        style="width: 100%"
        height="100%"
        header-row-class-name="out-Table-header"
        row-key="projectId"
        :expand-row-keys="expandRowKeys.map(item => item)"
        @expand-change="setExpandRowKeys"
      >
        <el-table-column type="selection" width="35" align="right" />
        <el-table-column type="expand" width="30">
          <template slot-scope="scope">
            <el-table
              :data="scope.row.bidList"
              :merge-columns="mergeColumns"
              border
              highlight-current-row
              style="width: 100%"
              row-class-name="in-Table"
              header-row-class-name="in-Table-header"
              :cell-class-name="handleCellClassName"
            >
              <el-table-column type="selection" width="53" align="center" />
              <el-table-column prop="bidSectionName" label="标段名称" min-width="223" />
              <el-table-column prop="bidSectionCode" label="标段编号" min-width="182" />
              <el-table-column prop="openStartTime" label="开标时间" min-width="148">
                <template slot-scope="bidScope">
                  {{ formatDateFn(bidScope.row.openStartTime, "yyyy-MM-dd HH:mm") }}
                </template>
              </el-table-column>
              <el-table-column prop="openAddress" label="开标室" min-width="120" />
              <el-table-column prop="evaluationAddress" label="评标室" min-width="120" />
              <el-table-column prop="witnessSubTaskName" label="见证阶段" min-width="80" show-overflow-tooltip />
              <el-table-column prop="witnessUserName" label="见证人" min-width="110" show-overflow-tooltip />
              <el-table-column prop="witnessAllocateUserName" label="分配人" min-width="80" show-overflow-tooltip />
              <el-table-column prop="witnessSubTaskAllocateTime" label="分配时间" min-width="148" show-overflow-tooltip>
                <template slot-scope="bidScope">
                  {{ formatDateFn(bidScope.row.witnessSubTaskAllocateTime, "yyyy-MM-dd HH:mm") }}
                </template>
              </el-table-column>
              <el-table-column label="操作" min-width="110">
                <template slot-scope="scopecld">
                  <el-button
                    v-if="scopecld.row.OPERATE_UPDATE_WITNESS_USER"
                    type="text"
                    @click="updateClickFn(scopecld, scope)"
                  >
                    更改见证人
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column type="index" label="序号" width="53" align="center">
          <template slot-scope="scope">
            {{ (pageObj.currentPage - 1) * pageObj.pageSize + scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="projectName" label="项目名称" min-width="223" show-overflow-tooltip />
        <el-table-column prop="projectCode" label="项目编号" min-width="167" show-overflow-tooltip />
        <el-table-column
          prop="industry"
          label="行业类别"
          min-width="158"
          :formatter="formatterIndustry"
          show-overflow-tooltip
        />
        <el-table-column
          prop="tenderMode"
          label="交易方式"
          min-width="158"
          :formatter="formatterTenderMode"
          show-overflow-tooltip
        />
        <el-table-column
          prop="qualificationExamMethod"
          label="资审方式"
          min-width="159"
          :formatter="formatterQualificationExamMethod"
          show-overflow-tooltip
        />
        <el-table-column prop="businessUnit" label="业务部门" min-width="159" show-overflow-tooltip />
        <el-table-column prop="operateUserName" label="经办人" min-width="159" show-overflow-tooltip />
        <el-table-column label="操作" min-width="160">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.OPERATE_PROJECT_DETAIL"
              type="text"
              @click="handleViewDetailFn(scope.row.projectId)"
            >
              项目详情
            </el-button>
            <el-button
              v-if="scope.row.OPERATE_UPDATE_WITNESS_USER"
              type="text"
              @click="updateWitnessPeopleAll(scope, 'OPERATE_UPDATE_WITNESS_USER')"
            >
              更改见证人
            </el-button>
            <!--
            1: 开始见证
            开标开始见证
            评标开始见证
            移交见证
            -->


            <!--            <el-button v-if="scope.row.OPERATE_CANCEL_WITNESS" type="text" @click="handleCancelWitness(scope.row)">-->
            <!--              取消见证-->
            <!--            </el-button>-->
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="layout-footer">
      <pagination
        v-if="pageObj.total > pageObj.pageSizes[0]"
        :total="pageObj.total"
        :page.sync="pageObj.currentPage"
        :limit.sync="pageObj.pageSize"
        :page-sizes="pageObj.pageSizes"
        @pagination="witnessRecordDistributeListFn()"
      />
    </div>
    <!-- 定向分配见证人 -->
    <AssignDialog
      :show="assignShow"
      :type="assignType"
      :header-title="assignTitle"
      :data="assignData"
      :row-data="currentWitness"
      @close="assignCloseFn(arguments)"
      @submit="assignSubmitFn"
    />
    <!-- 项目详情弹窗 -->
    <!-- <ProjectDetailsDialog :visible.sync="detailDialogShow" :projectId="currentProjectId" :taskObj="TASKOBJ" /> -->
    <ProjectDetailsDrawer
      :visible.sync="detailDialogShow"
      @closeDrawer="closeDrawerFn"
      :project-id="currentProjectId"
      :task-obj="TASKOBJ"
    />
  </div>
</template>
<script>
  // 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
  import { moduleInit, witnessRecordDistributeList, witnessProjectBidSectionDetail } from "../../../../api/api";
  import { FindArrayFn, getFirstAndSecondLevel, formatDateFn, isOneH } from "../../../../utils/utils";
  import AssignDialog from "../../../../components/dialog/AssignDialog.vue";
  import ProjectDetailsDrawer from "../../../../components/dialog/ProjectDetailsDrawer.vue";
  import { GZAPI_EvaluationTime } from "../../../../../gz_plugin/api";
  export default {
    // 引入组件
    components: { AssignDialog, ProjectDetailsDrawer },
    props: {},
    data() {
      // 这里存放数据
      return {
        expandRowKeys: [], // 用来更新表格后,默认障碍修改的表格
        currentWitness: {},
        assignData: [],
        assignShow: false,
        assignTitle: "",
        assignType: "",
        searchForm: {
          industry: [],
          industrySecondLevel: [], // 选中的行业类别的二级菜单的数组集合
          tenderMode: "",
          zsType: "",
          date: [this.$moment(new Date()).format("yyyy-MM-DD"), this.$moment(new Date()).format("yyyy-MM-DD")],
          keywords: ""
        },
        TASKOBJ: {}, // 后端返回的所有下拉映射值数据
        tenderModeIndustryObj: {}, // 依据行业类别一级菜单分组显示的交易方式
        industryTypeAndIndustryData: [], // 行业类别
        tenderModeOptionsObj: {}, // 交易方式下拉
        zsTypeOptionsObj: {}, // 资审方式
        pickerOptions: {
          shortcuts: [
            {
              text: "最近一周",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                picker.$emit("pick", [start, end]);
              }
            },
            {
              text: "最近一个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                picker.$emit("pick", [start, end]);
              }
            },
            {
              text: "最近三个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                picker.$emit("pick", [start, end]);
              }
            }
          ]
        },
        tableData: [],
        tableLoading: false,
        mergeColumns: [
          {
            key: "bidSectionName",
            conditions: ["bidSectionName", "bidSectionCode"]
          },
          {
            key: "bidSectionCode",
            conditions: ["bidSectionName", "bidSectionCode"]
          },
          {
            key: "openStartTime",
            conditions: ["bidSectionName", "bidSectionCode"]
          },
          {
            key: "openAddress",
            conditions: ["bidSectionName", "bidSectionCode"]
          },
          {
            key: "evaluationAddress",
            conditions: ["bidSectionName", "bidSectionCode"]
          }
        ],
        pageObj: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          pageSizes: [10, 20, 30]
        },
        detailDialogShow: false, // 是否展示项目详情弹窗
        currentProjectId: "" // 当前操作的项目id
      };
    },
    // 监听属性 类似于data概念
    computed: {
      wsData() {
        console.log("this.$websocket.getters.wsData", this.$websocket.getters.wsData);
        // return this.$websocket.getters.wsData;
        return this.$websocketNetty.getters.wsData;
      }
    },
    // 监控data中的数据变化
    watch: {
      wsData(val) {
        console.log("netty watch wsData", val);
        if (val) {
          this.witnessProjectBidSectionDetailFn(val);
        }
      }
    },
    // 生命周期 - 创建完成（可以访问当前this实例）
    created() {
      this.pageInitFn();
    },
    // 生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {},
    // 生命周期 - 销毁之前
    beforeDestroy() {},
    // 生命周期 - 销毁完成
    destroyed() {},
    deactivated() {},
    // 如果页面有keep-alive缓存功能，这个函数会触发
    activated() {
      console.log("activated");
      // 列表重新渲染
      this.witnessRecordDistributeListFn();
    },
    // 方法集合
    methods: {

      setExpandRowKeys(item) {
        const projectId = item.projectId || projectId;
        const index = this.expandRowKeys.indexOf(projectId);
        if (item === 'close') {
          this.expandRowKeys = [];
        } else if (index === -1) {
          this.expandRowKeys.push(projectId);
        } else if(index > -1) {
          this.expandRowKeys.splice(index, 1);
        }
      },

      // 随机分配
      async random() {
        const { success, message } = await GZAPI_EvaluationTime.random();
        if(success){
          this.$message.success('分配完成');
          this.handleSearchFn()
        } else {
          this.$message.warning(message);
        };
      },

      ...{ formatDateFn },
      pageInitFn() {
        clearTimeout(this.timeFlag);
        this.timeFlag = setTimeout(() => {
          this.moduleInitFn();
        }, 300);
      },
      searchInitDataFn() {
        this.industryTypeAndIndustryData = JSON.parse(JSON.stringify(this.TASKOBJ.industryTypeAndIndustry));
        this.TASKOBJ.industryTypeAndIndustry.forEach((item) => {
          item.BIDDING = {};
          item.children.forEach((itemB) => {
            itemB.childrenTenderMode.forEach((itemC) => {
              // console.log("itemC", itemC.value);
              item.BIDDING[itemC.value] = itemC.label;
              // 交易方式
              if (!this.tenderModeOptionsObj[itemC.value]) {
                this.tenderModeOptionsObj[itemC.value] = itemC.label;
              }
              // 资审方式
              itemC.children.forEach((itemD) => {
                // console.log("itemD", itemD.value);
                if (!this.zsTypeOptionsObj[itemD.value]) {
                  this.zsTypeOptionsObj[itemD.value] = itemD.label;
                }
              });
            });
          });
        });
      },
      async moduleInitFn() {
        try {
          const res = await moduleInit({ moduleName: "CREATETASK" });
          if (res.success) {
            this.TASKOBJ = res.data;
            // 依据行业类别的一级分类分组显示交易方式
            // for (let i = 0; i < res.data.industryTypeAndTenderMode.length; i++) {
            //   const obj = res.data.industryTypeAndTenderMode[i];
            //   this.tenderModeIndustryObj[obj.value] = obj.children;
            // }
            this.TASKOBJ.industryTypeAndIndustry.forEach((item) => {
              item.children.forEach((itemB) => {
                // children会在菜单中显示
                if (itemB.children) {
                  itemB.childrenTenderMode = JSON.parse(JSON.stringify(itemB.children));
                  itemB.children = null;
                } else {
                  itemB.childrenTenderMode = JSON.parse(JSON.stringify(itemB.childrenIndustry));
                }
              });
            });
            this.searchInitDataFn();
            setTimeout(() => {
              this.industryChange([]); // 获取交易方式的下拉及获取列表数据
            }, 300);
            // this.witnessRecordDistributeListFn(); // 获取列表
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (error) {
          console.log(error);
        }
      },
      // 行业类别发生变化，交易方式下拉选项联动
      industryChange(arr) {
        const obj = getFirstAndSecondLevel(arr);
        this.searchForm.industrySecondLevel = obj.secondLevel;
        // this.tenderModeOptionsObj = {};
        // if (obj.firstLevel.length === 0) {
        //   // 1. 当行业类型没有值时，交易方式默认返回所有的下拉值
        //   for (const key in this.tenderModeIndustryObj) {
        //     this.tenderModeOptionsObj = this.getTenderModeOptions(
        //       this.tenderModeOptionsObj,
        //       this.tenderModeIndustryObj[key]
        //     );
        //   }
        // } else {
        //   // 2. 有值时，依据一级行业的一级菜单获取交易方式的下拉
        //   for (let i = 0; i < obj.firstLevel.length; i++) {
        //     this.tenderModeOptionsObj = this.getTenderModeOptions(
        //       this.tenderModeOptionsObj,
        //       this.tenderModeIndustryObj[obj.firstLevel[i]]
        //     );
        //   }
        // }
        this.handleSearchFn();
      },
      getTenderModeOptions(obj, arr) {
        for (let i = 0; i < arr.length; i++) {
          // eslint-disable-next-line no-prototype-builtins
          if (!obj.hasOwnProperty(arr[i].value)) {
            obj[arr[i].value] = arr[i].label;
          }
        }
        return obj;
      },
      // 搜索查询
      handleSearchFn() {
        this.pageObj.total = 0;
        this.pageObj.currentPage = 1;
        this.witnessRecordDistributeListFn();
      },
      // 见证审核记录列表查询
      async witnessRecordDistributeListFn() {
        if (this.apiflag) {
          return;
        }
        this.apiflag = setTimeout(() => {
          clearTimeout(this.apiflag);
          this.apiflag = null;
        }, 500);
        try {
          this.tableLoading = true;
          this.tableData = [];
          const params = {
            industryList: this.searchForm.industrySecondLevel,
            tenderMode: this.searchForm.tenderMode,
            qualificationExamMethod: this.searchForm.zsType,
            search: this.searchForm.keywords,
            currentPage: this.pageObj.currentPage,
            pageSize: this.pageObj.pageSize
          };
          if (this.searchForm.date && this.searchForm.date.length) {
            params.startTime = `${this.searchForm.date[0]} 00:00:00`;
            params.endTime = `${this.searchForm.date[1]} 23:59:59`;
          }
          const res = await witnessRecordDistributeList(params);
          // console.log("assignData", assignData);
          // const res = assignData;
          this.tableLoading = false;
          if (res.success) {
            const date = new Date();
            const arr = [];
            let proButtonCodeMap; // 收集项目中, 每一个标段的按钮,
            res.data.result.forEach((proItem) => {
              proButtonCodeMap = new Map();


              const proObj = proItem.data;
              proItem.pageOpers.forEach((val) => {
                proObj[val.code] = true;
              });
              proObj.bidList = [];
              proItem.data.bidSectionVOList.forEach((bidItem) => {
                const bidObj = this.$cafeUtils.deepClone(bidItem);
                this.$delete(bidObj, "witnessSubTaskVOList");
                let newBidObj = {};
                bidItem.witnessSubTaskVOList.result.forEach((witnessItem, index) => {
                  newBidObj = { ...bidObj, ...witnessItem.data };
                  witnessItem.pageOpers.forEach((val) => {
                    let codeTotal = 0;
                    if(proButtonCodeMap.has(val.code)){
                      codeTotal = proButtonCodeMap.get(val.code);
                    }
                    proButtonCodeMap.set(val.code, codeTotal += 1);
                    newBidObj[val.code] = true;
                  });
                  // 判断标段表格框是否变细，除了第一个均变细
                  if (index < bidItem.witnessSubTaskVOList.result.length - 1) {
                    newBidObj.thinBorder = true;
                  }

                  if(!isOneH(newBidObj.evaluationStartTime, date)){
                    newBidObj.evaluationAddress = '**'
                  }
                  proObj.bidList.push(newBidObj);
                });
              });
              // 当项目中的标包有一个非未见证, 那么项目级的为见证按钮不可见
              proButtonCodeMap.forEach((value, key) => {
                if (value > 0) {
                  proObj[key] = true;
                }
              })

              arr.push(proObj);
            });
            console.log("arr", arr);
            this.tableData = arr;
            this.pageObj.total = res.data.pageBean.count;
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (error) {
          console.log(error);
          this.tableLoading = false;
        }
      },
      // 见证详细
      async witnessProjectBidSectionDetailFn(data) {
        // this.tableLoading = true;
        // this.tableData = [];
        console.log("data", data);
        if (!data || !data.projectId) {
          return;
        }
        const p = {
          projectId: data.projectId,
          bidSectionIdList: data.bidSectionIdList
        };
        console.log("p", p);
        try {
          const res = await witnessProjectBidSectionDetail(p);
          console.log("res", res);
          if (res.success) {
            // let i, j;
            this.tableData.forEach((item) => {
              if (item.projectId === data.projectId) {
                // i = index;
                // 项目名称 , 项目编号,行业类别,交易方式,资审方式
                console.log("item", item);
                const project = res.data.witnessProjectBaseInfo;
                const { bidSectionInfoList } = res.data;
                console.log("project", project);
                item.projectName = project.projectName;
                item.projectCode = project.projectCode;
                item.industry = project.industry;
                item.industryType = project.industryType;
                item.tenderMode = project.tenderMode; // 交易方式
                // item.sourceSystemCode = project.sourceSystemCode;
                // item.sourceSystemName = project.sourceSystemName;
                item.businessUnit = project.businessUnit;
                item.operateUserName = project.operateUserName;
                item.qualificationExamMethod = project.qualificationExamMethod; // 资审方式
                bidSectionInfoList.forEach((itemC) => {
                  // table的数据
                  item.bidList.forEach((itemB) => {
                    const flag = itemC.bidSectionCode === itemB.bidSectionCode;
                    if (flag) {
                      itemB.evaluationAddress = itemC.evaluationAddress;
                      itemB.openAddress = itemC.openAddress;
                      itemB.openStartTime = itemC.openStartTime;
                      itemB.bidSectionName = itemC.bidSectionName;
                      itemB.bidSectionCode = itemC.bidSectionCode;
                      // itemB.witnessAllocateUserName =
                      console.log("itemB", itemB);
                      itemC.witnessSubTaskVOList.forEach((itemD) => {
                        console.log("itemD", itemD);
                        if (itemD.witnessSubTaskId === itemB.witnessSubTaskId) {
                          console.log("1111", itemD.witnessSubTaskName);
                          itemB.witnessAllocateUserName = itemD.witnessAllocateUserName;
                          itemB.witnessUserName = itemD.witnessUserName;
                          itemB.witnessSubTaskAllocateTime = itemD.witnessSubTaskAllocateTime;
                        }
                      });
                      // itemB.bidSectionCode = itemC.witnessSubTaskVOList;
                      // itemB = itemC;
                      // this.$set(this.tableData[index].bidList, indexB, itemC);
                    }
                  });
                });
              }
            });
            this.tableData;
            // this.$set(this.tableData, i, Obj);
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (error) {
          console.warn(error);
        }
      },
      // 设置表格单元格样式
      handleCellClassName({ row, columnIndex }) {
        // 由于第2、3、4、5、6列进行了单元格合并，使用的是当前标段第一行的border，故不需要变细
        let className = "";
        if (
          row.thinBorder &&
          columnIndex !== 1 &&
          columnIndex !== 2 &&
          columnIndex !== 3 &&
          columnIndex !== 4 &&
          columnIndex !== 5
        ) {
          className = "in-Table-cell";
        }
        return className;
      },
      formatterIndustry(row) {
        let str = "";
        if (row.industryType) {
          const obj = FindArrayFn(this.TASKOBJ.industryTypeAndIndustry, row.industryType);
          str = obj.label;
        }
        if (row.industry) {
          const inObj = FindArrayFn(this.TASKOBJ.industryTypeAndIndustry, row.industry);
          str = `${str}/${inObj.label}`;
        }
        return str;
      },
      formatterTenderMode(row) {
        let str = "";
        if (row.tenderMode) {
          str = this.tenderModeOptionsObj[row.tenderMode];
        }
        return str;
      },
      formatterQualificationExamMethod(row) {
        let str = "";
        if (row.qualificationExamMethod) {
          const obj = FindArrayFn(this.TASKOBJ.qualificationExamMethods, row.qualificationExamMethod);
          str = obj.label;
        }
        return str;
      },
      closeDrawerFn() {
        console.log("closeDrawerFn");
        this.currentProjectId = "";
        this.detailDialogShow = false;
      },
      // 项目详情
      handleViewDetailFn(projectId) {
        this.currentProjectId = projectId;
        this.detailDialogShow = true;
      },
      // 取消见证
      handleCancelWitness(row) {
        console.log("row", row);
      },
      cancelWitnessFn({ row }) {
        console.log("row", row.data);
        this.cancelVisible = true;
        this.currentWitness = row.data;
        console.log("row", row);
        this.refreshCode();
      },
      assignSubmitFn(row) {
        console.log("row", row);
      },
      // 更改见证人 弹框关闭
      async assignCloseFn(arg) {
        console.log("arg", arg);
        console.log("this.currentWitness", this.currentWitness);
        console.log("this.currentProjectObj", this.currentProjectObj);
        // return;
        if (arg[0] === "save") {
          // arg[1][0].userName;
          // this.currentWitness;
          // this.currentProjectObj.$index;
          const p = {
            projectId: this.currentProjectObj.row.projectId,
            bidSectionIdList: [this.currentWitness.bidSectionId]
          };
          this.witnessProjectBidSectionDetailFn(p);
          // // 见证人
          // this.$set(
          //   this.tableData[this.currentProjectObj.$index].bidList[this.currentWitnessIndex],
          //   "witnessUserName",
          //   arg[1][0].userName
          // );
          // // 分配人
          // this.$set(
          //   this.tableData[this.currentProjectObj.$index].bidList[this.currentWitnessIndex],
          //   "witnessAllocateUserName",
          //   this.$store.getters.username
          // );
          // console.log(this.currentProjectObj.$index);
          // console.log(this.tableData[this.currentProjectObj.$index]);
          // console.log([this.currentWitnessIndex]);
          // this.handleSearchFn();
        } else if(arg[0] === "refresh"){
          // 刷新列表
          if(!this.isAllUpdateWitnessPeople){
            this.expandRowKeys = [this.currentWitness.projectId];
          } else {
            this.isAllUpdateWitnessPeople = false;
          }

          await this.witnessRecordDistributeListFn()
        }
        this.assignShow = false;
        this.assignTitle = "";
        this.assignType = "";
      },
      // 更改见证人
      updateClickFn({ row, $index }, scope) {
        console.log("row111", row);
        this.currentProjectObj = scope;
        this.currentWitnessIndex = $index;
        this.currentWitness = row; // { witnessSubTaskId: row.witnessSubTaskId };
        this.assignShow = true;
        this.assignTitle = "更改见证人";
      },
      // 批量审核
      handleBatchApprove() {
        return this.$message({
          type: "warning",
          message: "功能待开发"
        });
      },

      // 批量更改见证人
      updateWitnessPeopleAll({ row, $index }) {
        this.isAllUpdateWitnessPeople = true;
        this.currentWitness = row;
        this.currentWitnessIndex = $index;
        this.assignShow = true;
        this.assignTitle = "更改项目见证人";
      }
    }
  };
</script>
<style lang="scss" scoped>
  .witness-result {
    width: 76px;
    height: 20px;
    line-height: 20px;
    background: #fc9306;
    border-radius: 10px;
    color: #fff;
    font-size: 12px;
    text-align: center;
  }
</style>
